package com.sunlands.deskmate.message.handler.sender.trigger;

import com.sunlands.deskmate.channel.ChannelInfo;
import lombok.Data;

/**
 *
 * 封装目标对象和msgId
 *
 * @author anjunling@sunlands.com
 * @author liude
 */
@Data
public class TriggerEvent {

    private String event;

    private Long userId;

    private Long msgId;

    private String type;

    private String action;

    public TriggerEvent(TriggerEventEnum eventEnum, String sessionKey) {
        this.event = eventEnum.getEvent();

        ChannelInfo channelInfo = ChannelInfo.parseSessionKey(sessionKey);

        this.userId = channelInfo.getUserId();
    }

    public TriggerEvent(TriggerEventEnum eventEnum, ChannelInfo channelInfo) {
        this.event = eventEnum.getEvent();
        this.userId = channelInfo.getUserId();
    }

    public TriggerEvent(TriggerEventEnum eventEnum, ChannelInfo channelInfo, Long msgId, String type, String action) {
        this.event = eventEnum.getEvent();
        this.userId = channelInfo.getUserId();
        this.msgId = msgId;
        this.type = type;
        this.action = action;
    }

    public String getSessionKey() {
        return new ChannelInfo(this.userId).getSessionKey();
    }
}
